package com.tzg157.fitness.flume;

import org.apache.flume.api.RpcClient;
import org.apache.flume.api.RpcClientFactory;
import org.apache.flume.event.EventBuilder;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

public class FlumeAppender {

    public static final String IP = "localhost";
    public static final int PORT = 44444;

    public static void main(String[] args) throws Exception {
        Map<String,Object> reserveDto = new HashMap<>();
        reserveDto.put("ip", IP);
        reserveDto.put("port", PORT);
        RpcClient client = RpcClientFactory.getDefaultInstance(IP, PORT);
//        client.append(EventBuilder.withBody(JSONUtil.toJsonStr(reserveDto), StandardCharsets.UTF_8));
        client.append(EventBuilder.withBody("27,123", StandardCharsets.UTF_8));
        client.close();
    }
}
